package com.yanqu.road.server.cmd.orewar.cross;

import com.yanqu.road.entity.crossorewar.CrossUserOrePit;
import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.pb.orewar.OreWarProto;
import com.yanqu.road.server.cmd.base.AbstractCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.gameplayer.GamePlayer;
import com.yanqu.road.server.protocol.Protocol;

import java.util.ArrayList;
import java.util.List;

@Cmd(code = Protocol.S_CROSS_ORE_WAR_PIT_LIST, desc = "跨服坑位详细信息返回")
public class CrossOrePitListMsgCmd extends AbstractCommand {

	private int activityId;

	List<CrossUserOrePit> crossUserOrePitList = new ArrayList<>();

	@Override
	public boolean parseData(YanQuMessage packet) throws Exception {
		return true;
	}

	@Override
	public void execute(GamePlayer player, YanQuMessage packet) throws Exception {
		OreWarProto.CrossOrePitListMsg crossSyncMsg = OreWarProto.CrossOrePitListMsg.parseFrom(packet.getBytes());
		activityId = crossSyncMsg.getActivityId();
		//crossUserOrePitList = OreWarPb.parseCrossOrePitList(crossSyncMsg.getOrePitListList());
		//OreWarProto.OrePitListMsg.Builder respMsg = OreWarPb.parseCrossOrePitListMsg(crossUserOrePitList);
		OreWarProto.OrePitListMsg.Builder respMsg = OreWarProto.OrePitListMsg.newBuilder();
		List<OreWarProto.CrossOrePitTempMsg> orePitListList = crossSyncMsg.getOrePitListList();
		for (OreWarProto.CrossOrePitTempMsg tempMsg : orePitListList) {
			OreWarProto.OrePitTempMsg.Builder msg = OreWarProto.OrePitTempMsg.newBuilder();
			msg.setActivityId(tempMsg.getActivityId());
			msg.setPitId(tempMsg.getPitId());
			msg.setStationId(tempMsg.getStationId());
			msg.setUserId(tempMsg.getUserId());
			msg.setServerId(tempMsg.getServerId());
			msg.setNickName(tempMsg.getNickName());
			msg.setDecoration(tempMsg.getPlayerBaseData().getDecoration());
			msg.setTitleId(tempMsg.getPlayerBaseData().getTitleId());
			msg.setCity(tempMsg.getPlayerBaseData().getCity());
			msg.setUnionName(tempMsg.getPlayerBaseData().getUnionName());
			msg.setUnionUid(tempMsg.getPlayerBaseData().getUnionUid());
			respMsg.addOrePitList(msg);
		}
		respMsg.setActivityId(activityId);
		player.sendPacket(Protocol.U_ORE_WAR_STATION_DETAIL, respMsg);
	}

	@Override
	public void sendData(GamePlayer player) {

	}
}
